const {http ,handleStr} = require("../../utils/index")
Page({
  data:{
    album:[]
},
onLoad(){
    var url = "http://47.108.197.28:3000/top/album"
    http({
        url,
        success:result=>{
            this.handleHttpData(result) 
        }
    })
},
handleHttpData(result){
        var album = []
        var albums = result.data.albums;
         albums.forEach(item=>{
                var {id,name,picUrl,artist} = item
                
                album.push(
                {   id,
                    name : handleStr(name),
                    picUrl,
                    artist:artist.name
                }
                )
                
            })
            
            this.setData({
                album,
            })
},
handleItem(event){
    var {aid} = event.currentTarget.dataset;
    wx.navigateTo({
        url: `/pages/detail/detail?id=${aid}`
    });
}
})
